<?php if (!defined('BASEPATH')) exit('No direct script access allowed.');
/*****
  * The Pagination helper cuts out some of the bumf of normal pagination
  * @author		Philip Sturgeon
  * @email		email@philsturgeon.co.uk
  * @filename	pagination_helper.php
  * @title		Pagination Helper
  * @version	1.0
  *****/

function create_pagination($uri, $total_rows, $limit, $uri_segment,$add_select_page = 0, $option = array('navigate_function' => 'navigate', 'limit_id' => 'limit')) {
	
	$CI =& get_instance();
	$CI->load->library('pagination');
	$CI->lang->load('common');
	//die($CI->lang->line('first_link'));
	
	$current_page = $uri_segment; //
	//$current_page = $CI->uri->segment($uri_segment, 0);
	
	// Initialize pagination
    $config['base_url'] = site_url().$uri.'/';
	$config['total_rows'] = $total_rows; // count all records
	$config['per_page'] = $limit === NULL ? $CI->settings->item('records_per_page') : $limit;
	$config['uri_segment'] = $uri_segment;
	$config['page_query_string'] = FALSE;
	
	$config['num_links'] = 4;
		
	
	$config['first_link'] = $CI->lang->line('first_link');
	$config['first_tag_open'] = '<div class="button2-right"><span class="start">';
	$config['first_tag_open_off'] = '<div class="button2-right off"><span class="start">';
	$config['first_tag_close'] = '</span></div>';
	
	$config['prev_link'] = $CI->lang->line('prev_link');
	$config['prev_tag_open'] = '<div class="button2-right"><span class="prev">';
	$config['prev_tag_open_off'] = '<div class="button2-right off"><span class="prev">';
	$config['prev_tag_close'] = '</span></div>';

	$config['cur_tag_open'] = '<span class="current roundedBordersLite">';
	$config['cur_tag_close'] = '</span>';
	
	$config['num_tag_open'] = '<span>';
	$config['num_tag_close'] = '</span>';
	
	$config['next_link'] = $CI->lang->line('next_link');
	$config['next_tag_open'] = '<div class="button3-left"><span class="next">';
	$config['next_tag_open_off'] = '<div class="button3-left off"><span class="next">';
	$config['next_tag_close'] = '</span></div>';
	
	$config['last_link'] = $CI->lang->line('last_link');
	$config['last_tag_open'] = '<div class="button3-left"><span class="end">';
	$config['last_tag_open_off'] = '<div class="button3-left off"><span class="end">';
	$config['last_tag_close'] = '</span></div>';
	
	$config['page_location_tag_open'] = '<span>';
	$config['page_location_tag_close'] = '</span>';
	$config['page_location'] = $CI->lang->line('page_location');
	
	$config['add_select_page'] = $add_select_page;
	
	//KhoiNM: add custom navigate function
	$config['navigate_function'] = isset($option['navigate_function']) ? $option['navigate_function'] : 'navigate';
	$config['limit_id'] = isset($option['limit_id']) ? $option['limit_id'] : 'limit';
	
	$CI->pagination->initialize($config); // initialize pagination
	return array(
		'current_page' 	=> $current_page,
		'per_page' 		=> $config['per_page'],
		'limit'			=> array($config['per_page'], $current_page),
		'limit_id'		=> $config['limit_id'],
		'links' 		=> $CI->pagination->create_links()
	);
}

?>